﻿// See https://aka.ms/new-console-template for more information

var httpClient = new HttpClient();

try {
    var response = await httpClient.GetAsync(
        "http://no.such.url");
    response.EnsureSuccessStatusCode();
} catch (HttpRequestException hre) {
    Console.WriteLine(
        $"Error with status code {hre.StatusCode}");
}